﻿using CommunityToolkit.Mvvm.ComponentModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using XYAC.Framework.MonitorTireMaterialManual.DataExporter;
using XYAC.Framework.MonitorTireMaterialManual.OracleRemoteDB;

namespace XYAC.Framework.MonitorTireMaterialManual.DTO
{
    public partial class SemiSteelSideInspectionReport : ObservableObject
    {
        public SemiSteelSideInspectionReport()
        {
            LastSyncDate = DateTime.Now;
        }
        [ObservableProperty]
        public int _iD;
        [ObservableProperty]
        public bool? _isDeleted;
        //public string? UserId { get; set; }
        /// <summary>
        /// 补偿系数
        /// </summary>
        [ObservableProperty]
        public double _compensationCoefficient;

        /// <summary>
        /// 规格号
        /// </summary>
        [Description("规格号")]
        [ObservableProperty]
        public string _specName;

        /// <summary>
        /// 实际规格号
        /// </summary>
        [Description("实际规格号")]
        [ObservableProperty]
        private string _specNameInfact;

        /// <summary>
        /// 面积差比
        /// </summary>
        [Description("面积差比")]
        [ObservableProperty]
        public double _totalArea;
        [ObservableProperty]
        public double _totalLeftArea;
        [ObservableProperty]
        public double _totalRightArea;
        [ObservableProperty]
        public double _measureArea;
        [ObservableProperty]
        public double _measureLeftArea;
        [ObservableProperty]
        public double _measureRightArea;

        [ObservableProperty]
        public string _serialNumber;
        [ObservableProperty]
        public string _scanedDatetime;
        
        /// <summary>
        /// 总宽标准
        /// </summary>
        [Description("总宽标准")]
        [ObservableProperty]
        public double _totalWidth_Stable;

        /// <summary>
        /// 总宽扫描
        /// </summary>
        [ObservableProperty]
        public double _totalWidth_Scan;
        /// <summary>
        /// 总宽扫描-左
        /// </summary>
        [Description("总宽扫描-左")]
        [ObservableProperty]
        public double _totalWidth_ScanLeft;
        /// <summary>
        /// 总宽扫描-右
        /// </summary>
        [Description("总宽扫描-右")]
        [ObservableProperty]
        public double _totalWidth_ScanRight;

        /// <summary>
        /// 总宽对称性
        /// </summary>
        [Description("总宽对称性")]
        [ObservableProperty]
        public double _totalWidth_Symmetry;

        /// <summary>
        /// 胎侧厚度标准
        /// </summary>
        [Description("胎侧厚度标准")]
        [ObservableProperty]
        public double _sidewallThickness_Stable;

        /// <summary>
        /// 胎侧厚度扫描-左
        /// </summary>
        [Description("胎侧厚度扫描-左")]
        [ObservableProperty]
        public double _sidewallThickness_ScanLeft;
        /// <summary>
        /// 胎侧厚度扫描-右
        /// </summary>
        [ObservableProperty]
        public double _sidewallThickness_ScanRight;

        /// <summary>
        /// 胎侧厚度对称性
        /// </summary>
        [Description("胎侧厚度对称性")]
        [ObservableProperty]
        public double _sidewallThickness_Symmetry;
        /// <summary>
        /// RC胶厚度标准
        /// </summary>
        [Description("RC胶厚度标准")]
        [ObservableProperty]
        public double _rCRubberThickness_Stable;
        /// <summary>
        /// RC胶厚度扫描左
        /// </summary>
        [Description("RC胶厚度扫描左")]
        [ObservableProperty]
        public double _rCRubberThickness_ScanLeft;
        /// <summary>
        /// RC胶厚度扫描右
        /// </summary>
        [Description("RC胶厚度扫描右")]
        [ObservableProperty]
        public double _rCRubberThickness_ScanRight;
        /// <summary>
        /// RC胶厚度对称性
        /// </summary>
        [Description("RC胶厚度对称性")]
        [ObservableProperty]
        public double _rCRubberThickness_Symmetry;
        /// <summary>
        /// 断面形状
        /// </summary>
        [Description("断面形状")]
        [ObservableProperty]
        public string? _crossSectionShape;
        /// <summary>
        /// 机台编号
        /// </summary>
        [Description("机台编号")]
        [ObservableProperty]
        public string? _eqp;
        /// <summary>
        /// 最后同步时间
        /// </summary>
        [ObservableProperty]
        public DateTime? _lastSyncDate;
        /// <summary>
        /// 同步状态
        /// </summary>
        [ObservableProperty]
        public Boolean _syncState   = false;
        [ObservableProperty]
        public double _xReference;
        /// <summary>
        /// 胎侧：TXT文档，[Keys]（总行数/2）+1行的左边数字
        /// 胎侧左宽度标准值
        /// </summary>
        [ObservableProperty]
        public float _sideLeftWidth;

        /// <summary>
        /// 胎侧：TXT文档，[Keys]（总行数/2）+1行的左边数字
        /// 胎侧右宽度
        /// </summary>
        [ObservableProperty]
        public float _sideRightWidth;

        /// <summary>
        /// 胎侧：TXT文档，[Keys]（总行数/2）+1行的左边数字
        /// 胎侧右宽度标准值
        /// </summary>
        [ObservableProperty] public float _sideRightWidthInfact;
        /// <summary>
        /// 胎侧：TXT文档，[Keys]（总行数/2）+1行的左边数字
        /// 胎侧左宽度,它实际上=XReference
        /// </summary>
        [ObservableProperty] public float _sideLeftWidthInfact;
        /// <summary>
        /// 胎侧左右宽度差(mm)
        /// ABS(左边宽度-右边宽度)
        /// </summary>
        [ObservableProperty]
        public float _leftRightSubstract;

        /// <summary>
        /// 边缘端点厚度(mm) = MeasureKeys第1组第2位
        /// </summary>
        [ObservableProperty]
        public float _endThick;

        [ObservableProperty]
        private string _userId;

        /// <summary>
        /// 当前班次
        /// </summary>
        [ObservableProperty]
        private string _currentShift;
        /// <summary>
        /// 总面积 %    实测值
        /// SemiSteelSideInspectionReport.AreaPercent
        /// </summary>
        [ObservableProperty]
        private float _data9;

        /// <summary>
        /// 胎侧宽度(mm)  左 标准
        /// SemiSteelSideInspectionReport.SideLeftWidth
        /// </summary>
        [ObservableProperty]
        private float _data10;
        /// <summary>
        /// 胎侧宽度(mm)  左 实测
        /// SemiSteelSideInspectionReport.SideLeftWidthInfact
        /// </summary>
        [ObservableProperty]
        private float _data14;

        /// <summary>
        /// 胎侧宽度(mm)  右 标准
        /// SemiSteelSideInspectionReport.SideRightWidth
        /// </summary>
        [ObservableProperty]
        private float _data11;
        /// <summary>
        /// 胎侧宽度(mm)  右 实测
        /// SemiSteelSideInspectionReport.SideRightWidthInfact
        /// </summary>
        [ObservableProperty]
        private float _data15;

        /// <summary>
        /// 胎侧左右宽度差(mm) 实测
        /// SemiSteelSideInspectionReport.LeftRightSubstract
        /// </summary>
        [ObservableProperty]
        private float _data18;

        /// <summary>
        /// 胎侧左右厚度差(mm) 实测值：
        /// ABS(左边厚度-右边厚度)
        /// </summary>
        [ObservableProperty]
        private float _data27;
        /// <summary>
        /// RC左右厚度差(mm) 实测值:
        /// ABS（左边厚度-右边厚度）
        /// </summary>
        [ObservableProperty]
        private float _data35;
        /// <summary>
        /// 边缘端点厚度(mm) 实测值
        /// SemiSteelSideInspectionReport.EndThick
        /// </summary>
        [ObservableProperty]
        private float _data37;
        /// <summary>
        /// 其它点厚度(mm) 
        /// </summary>
        [ObservableProperty]
        private string _checkPoint38= "True";
        /// <summary>
        /// 其它点厚度(mm)
        /// </summary>
        [ObservableProperty]
        private string _checkPoint39 = "True";


        [ObservableProperty]
        private float _manuData10D;
        [ObservableProperty]
        private float _manuData10F;
        [ObservableProperty]
        private float _manuData11D;
        [ObservableProperty]
        private float _manuData11F;

        [ObservableProperty]
        private float _manuData13D;
        [ObservableProperty]
        private float _manuData13F;
        [ObservableProperty]
        private float _manuData14D;
        [ObservableProperty]
        private float _manuData14F;

        /// <summary>
        /// RC上宽度(mm) 左 标准
        /// </summary>
        [ObservableProperty]
        private float _manuData18D;
        /// <summary>
        /// RC上宽度(mm) 左 公差
        /// </summary>
        [ObservableProperty]
        private float _manuData18E;
        /// <summary>
        /// RC上宽度(mm) 左 实际测量值
        /// </summary>
        [ObservableProperty]
        private float _manuData18F;

        /// <summary>
        /// RC上宽度(mm) 右 标准
        /// </summary>
        [ObservableProperty]
        private float _manuData19D;
        /// <summary>
        /// RC上宽度(mm) 右 公差
        /// </summary>
        [ObservableProperty]
        private float _manuData19E;
        /// <summary>
        /// RC上宽度(mm) 右 实际测量值
        /// </summary>
        [ObservableProperty]
        private float _manuData19F;

        /// <summary>
        /// RC下宽度(mm) 左 标准
        /// </summary>
        [ObservableProperty]
        private float _manuData20D;
        /// <summary>
        /// RC下宽度(mm) 左 公差
        /// </summary>
        [ObservableProperty]
        private float _manuData20E;
        /// <summary>
        /// RC下宽度(mm) 左 实际测量值
        /// </summary>
        [ObservableProperty]
        private float _manuData20F;

        /// <summary>
        /// RC下宽度(mm) 右 标准
        /// </summary>
        [ObservableProperty]
        private float _manuData21D;
        /// <summary>
        /// RC下宽度(mm) 右 公差
        /// </summary>
        [ObservableProperty]
        private float _manuData21E;
        /// <summary>
        /// RC下宽度(mm) 右 实际测量值
        /// </summary>
        [ObservableProperty]
        private float _manuData21F;

        /// <summary>
        /// RC左右宽度差(mm) 标准
        /// </summary>
        [ObservableProperty]
        private float _manuData22D;
        /// <summary>
        /// RC左右宽度差(mm) 公差
        /// </summary>
        [ObservableProperty]
        private float _manuData22E;
        /// <summary>
        /// RC左右宽度差(mm) 实际测量值
        /// </summary>
        [ObservableProperty]
        private float _manuData22F;


        /// <summary>
        /// 白胶宽度(mm) 标准
        /// </summary>
        [ObservableProperty]
        private float _manuData23D;
        /// <summary>
        /// 白胶宽度(mm) 公差
        /// </summary>
        [ObservableProperty]
        private float _manuData23E;
        /// <summary>
        /// 白胶宽度(mm) 实际测量值
        /// </summary>
        [ObservableProperty]
        private float _manuData23F;

        /// <summary>
        /// 白胶厚度(mm) 标准
        /// </summary>
        [ObservableProperty]
        private float _manuData24D;
        /// <summary>
        /// 白胶厚度(mm) 公差
        /// </summary>
        [ObservableProperty]
        private float _manuData24E;
        /// <summary>
        /// 白胶厚度(mm) 实际测量值
        /// </summary>
        [ObservableProperty]
        private float _manuData24F;

        /// <summary>
        /// 白胶底黑胶厚度(mm) 标准
        /// </summary>
        [ObservableProperty]
        private float _manuData25D;
        /// <summary>
        /// 白胶底黑胶厚度(mm) 公差
        /// </summary>
        [ObservableProperty]
        private float _manuData25E;
        /// <summary>
        /// 白胶底黑胶厚度(mm) 实际测量值
        /// </summary>
        [ObservableProperty]
        private float _manuData25F;


        /// <summary>
        /// 补强胶厚度(mm) 左 标准
        /// </summary>
        [ObservableProperty]
        private float _manuData26D;
        /// <summary>
        /// 补强胶厚度(mm) 左 公差
        /// </summary>
        [ObservableProperty]
        private float _manuData26E;
        /// <summary>
        /// 补强胶厚度(mm) 左 实际测量值
        /// </summary>
        [ObservableProperty]
        private float _manuData26F;

        /// <summary>
        /// 补强胶厚度(mm) 右 标准
        /// </summary>
        [ObservableProperty]
        private float _manuData27D;
        /// <summary>
        /// 补强胶厚度(mm) 右 公差
        /// </summary>
        [ObservableProperty]
        private float _manuData27E;
        /// <summary>
        /// 补强胶厚度(mm) 右 实际测量值
        /// </summary>
        [ObservableProperty]
        private float _manuData27F;

        /// <summary>
        /// 补强胶端点距离(mm)) 左 标准
        /// </summary>
        [ObservableProperty]
        private float _manuData28D;
        /// <summary>
        /// 补强胶端点距离(mm)) 左 公差
        /// </summary>
        [ObservableProperty]
        private float _manuData28E;
        /// <summary>
        /// 补强胶端点距离(mm)) 左 实际测量值
        /// </summary>
        [ObservableProperty]
        private float _manuData28F;

        /// <summary>
        /// 补强胶端点距离(mm)) 右 标准
        /// </summary>
        [ObservableProperty]
        private float _manuData29D;
        /// <summary>
        /// 补强胶端点距离(mm)) 右 公差
        /// </summary>
        [ObservableProperty]
        private float _manuData29E;
        /// <summary>
        /// 补强胶端点距离(mm)) 右 实际测量值
        /// </summary>
        [ObservableProperty]
        private float _manuData29F;

        /// <summary>
        /// 断面形状
        /// </summary>
        [ObservableProperty]
        private string _checkPoint40 = "True";

        /// <summary>
        /// 判定 41
        /// </summary>
        [ObservableProperty]
        private string _passStatus = "True";

        /// <summary>
        /// 备注
        /// </summary>
        [ObservableProperty]
        private string _remark;
        [ObservableProperty]
        private string _planId;
        [ObservableProperty]
        private string _shift;
        [ObservableProperty]
        private float _areaPercent;
        
        /// <summary>
        /// 将 SemiSteelSideInspectionReport 实例转换为 YB_PROCESS_STEP 实例。
        /// </summary>
        /// <param name="report">要转换的 SemiSteelSideInspectionReport 实例。</param>
        /// <returns>转换后的 YB_PROCESS_STEP 实例。</returns>
        public YB_PROCESS_STEP ToYB_PROCESS_STEP(DataFile dataFile)
        {
            //var dataFile = DataFile.FromSpecVal(this.SpecVal);
            var processStep = new YB_PROCESS_STEP
            {
                // 映射 SemiSteelSideInspectionReport 的字段到 RECORD16 至 RECORD32 
                PLAN_ID = this.PlanId,
                PART_NUMBER = this.SpecName,

                RECORD122 = this.TotalArea.ToString("F1"),//总面积设定值
                RECORD123 = this.MeasureArea.ToString("F1"),//总面积实际值
                RECORD124 = this.TotalLeftArea.ToString("F1"),//左面积设定值
                RECORD125 = this.MeasureLeftArea.ToString("F1"),//左面积实际值
                RECORD126 = this.TotalRightArea.ToString("F1"),//右面积设定值
                RECORD127 = this.MeasureRightArea.ToString("F1"),//右面积实际值
                RECORD128 = this.TotalWidth_Stable.ToString("F1"),//总宽设定值
                RECORD129 = this.TotalWidth_Scan.ToString("F1"),//总宽实际值

                //左侧宽设定值
                RECORD130 =this.Data10.ToString("F1"), //(this.TotalWidth_Scan / 2).ToString("F1"),//左侧宽设定值
                RECORD131 = this.Data14.ToString("F1"),// this.TotalWidth_ScanLeft.ToString("F1"),//左侧宽实际值

                //右侧宽设定值
                RECORD132 = this.Data11.ToString("F1"), //(this.TotalWidth_Stable / 2).ToString("F1"),//右侧宽设定值
                RECORD133 = this.Data15.ToString("F1"), //this.TotalWidth_ScanRight.ToString("F1"),//右侧宽实际值

                RECORD162 = this.SpecNameInfact,//   实际规格

                //胎侧厚度标准
                //RECORD140 = this.SidewallThickness_Stable.ToString("F1"),
                //RECORD141 = this.SidewallThickness_ScanLeft.ToString("F1"),
                //RECORD143 = this.SidewallThickness_ScanRight.ToString("F1"),
                RECORD163 = this.SidewallThickness_Symmetry.ToString("F1"),
                //RC胶厚度标准
                //RECORD169 = this.RCRubberThickness_Stable.ToString("F1"),
                //RECORD170 = this.RCRubberThickness_ScanLeft.ToString("F1"),
                //RECORD171 = this.RCRubberThickness_ScanRight.ToString("F1"),
                //RECORD172 = this.RCRubberThickness_Symmetry.ToString("F1"),

                RECORD134 = this.Data9.ToString("F1"),//   胎侧左厚度设定值
                RECORD135 = this.Data14.ToString("F1"),//   胎侧左厚度实际值
                RECORD136 = this.Data11.ToString("F1"),//   胎侧右厚度设定值
                RECORD137 = this.Data15.ToString("F1"),//   胎侧右厚度实际值
                RECORD165 = Math.Abs(Data14 - Data15).ToString("F1"),//  胎侧宽度对称性

                RECORD138 = this.ManuData23D.ToString("F1"),//   白胶宽度设定值
                RECORD139 = this.ManuData23E.ToString("F1"),//    白胶宽度公差
                RECORD140 = this.ManuData23F.ToString("F1"),//    白胶宽度实际值
                RECORD141 = this.ManuData24D.ToString("F1"),//    白胶厚度设定值
                RECORD142 = this.ManuData24E.ToString("F1"),//    白胶厚度公差
                RECORD143 = this.ManuData24F.ToString("F1"),//    白胶厚度实际值
                RECORD144 = this.ManuData25D.ToString("F1"),//    白胶底黑胶厚度设定值
                RECORD145 = this.ManuData25E.ToString("F1"),//    白胶底黑胶厚度公差
                RECORD146 = this.ManuData25F.ToString("F1"),//    白胶底黑胶厚度实际值
                RECORD147 = this.ManuData26D.ToString("F1"),//    补强胶左厚度设定值
                RECORD148 = this.ManuData26E.ToString("F1"),//  补强胶左厚度公差
                RECORD149 = this.ManuData26F.ToString("F1"),//  补强胶左厚度实际值
                RECORD150 = this.ManuData27D.ToString("F1"),//  补强胶右厚度设定值
                RECORD151 = this.ManuData27E.ToString("F1"),//  补强胶右厚度公差
                RECORD152 = this.ManuData27F.ToString("F1"),//  补强胶右厚度实际值
                RECORD153 = this.ManuData28D.ToString("F1"),//  补强胶左端点距离设定值
                RECORD154 = this.ManuData28E.ToString("F1"),//  补强胶左端点距离公差
                RECORD155 = this.ManuData28F.ToString("F1"),//  补强胶左端点距离实际值
                RECORD156 = this.ManuData29D.ToString("F1"),//  补强胶右端点距离设定值
                RECORD157 = this.ManuData29E.ToString("F1"),//  补强胶右端点距离公差
                RECORD158 = this.ManuData29F.ToString("F1"),//  补强胶右端点距离实际值


                RECORD166 = this.ManuData13D.ToString("F1"),//    RC胶左厚度设定值
                RECORD167 = this.ManuData14D.ToString("F1"),//    RC胶右厚度设定值
                RECORD168 = this.ManuData13F.ToString("F1"),//    RC胶左厚度实际值
                RECORD169 = this.ManuData14F.ToString("F1"),//    RC胶右厚度实际值
                RECORD170 = this.Data35.ToString("F1"),//  RC胶厚度对称性
                RECORD171 = this.Data37.ToString(),//  边缘端点厚度
                RECORD172 = this.CheckPoint38,//  其它点厚度设定值
                RECORD173 = this.CheckPoint39,//   其它点厚度实际值

                RECORD174 = this.ManuData18D.ToString("F1"),//    RC上左宽度设定值
                RECORD175 = this.ManuData18E.ToString("F1"),//    RC上左宽度公差
                RECORD176 = this.ManuData18F.ToString("F1"),//    RC上左宽度设实际值
                RECORD177 = this.ManuData19D.ToString("F1"),//    RC上右宽度设定值
                RECORD178 = this.ManuData19E.ToString("F1"),//    RC上右宽度公差
                RECORD179 = this.ManuData19F.ToString("F1"),//    RC上右宽度设实际值

                RECORD180 = Math.Abs(ManuData18F - ManuData19F).ToString("F1"),//    RC胶宽度对称性

                RECORD181 = this.ManuData20D.ToString("F1"),//    RC下左宽度设定值
                RECORD182 = this.ManuData20E.ToString("F1"),//    RC下左宽度公差
                RECORD183 = this.ManuData20F.ToString("F1"),//    RC下左宽度设实际值
                RECORD228 = this.ManuData21D.ToString("F1"),//    RC下右宽度设定值
                RECORD229 = this.ManuData21E.ToString("F1"),//    RC下右宽度公差
                RECORD230 = this.ManuData21F.ToString("F1"),//    RC下右宽度设实际值

                RECORD225 = this.PassStatus,//  判定结果
                RECORD226 = this.Remark, //备注
                RECORD227 = this.Shift,// 班次

                RECORD159 = this.UserId,
                //面积比
                RECORD160 = this.AreaPercent.ToString("F1"),
                RECORD161 = this.TotalWidth_Symmetry.ToString("F1"),
                //断面形状
                RECORD164 = this.CrossSectionShape,
                EQP = this.Eqp

            };
            //this.UpdateProcessStep(processStep, dataFile);
            return processStep;
        }

    }
}
